﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

public partial class Android_Book : System.Web.UI.Page
{
    protected class Book
    {
        public string Title { get; set; }
        public string Link { get; set; }
        public string Desc { get; set; }

    }

    protected void Page_Load(object sender, EventArgs e)
    {

        List<Book> book = new List<Book>();
        Dictionary<string, List<Book>> books = new Dictionary<string, List<Book>>();

        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
        SqlCommand cmd;
        SqlDataReader reader;



        try
        {
            conn.Open();

            cmd = new SqlCommand("SELECT * FROM Book WHERE Status=1 ", conn);
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                Book v = new Book() { Title = (String)reader["Title"], Link = "http://to-home.homeserver.com/Book/" + (String)reader["filename"], Desc = (String)reader["Description"] };
                book.Add(v);
            }
            books.Add("android", book);
            System.Web.Script.Serialization.JavaScriptSerializer objSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            Response.Write(objSerializer.Serialize(books));


        }
        finally
        {
            conn.Close();
        }



    }
}